import os
from celery import Celery, platforms

# 配置为ROOT可执行
platforms.C_FORCE_ROOT = True

# 设置django环境
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Reminder.settings')

# 创建一个Celery app
app = Celery('Reminder')

app.config_from_object('Reminder.celery_config', namespace='CELERY')

# eta countdown 等定时任务, 多次重发问题解决
max_timeout_in_seconds = 60 * 60 * 5  # 5小时
app.conf.broker_transport_options = {"visibility_timeout": max_timeout_in_seconds}

# 发现任务文件每个app下的task.py
app.autodiscover_tasks()
